# -*- test-case-name: tlpy.test.test_strcred -*-
#
# Copyright (c) tlpy.
# See LICENSE for details.

"""
Cred plugin for anonymous logins.
"""

from zope.interface import implements

from tlpy import plugin
from tlpy.cred.checkers import AllowAnonymousAccess
from tlpy.cred.strcred import ICheckerFactory
from tlpy.cred.credentials import IAnonymous


anonymousCheckerFactoryHelp = """
This allows anonymous authentication for servers that support it.
"""


class AnonymousCheckerFactory(object):
    """
    Generates checkers that will authenticate an anonymous request.
    """
    implements(ICheckerFactory, plugin.IPlugin)
    authType = 'anonymous'
    authHelp = anonymousCheckerFactoryHelp
    argStringFormat = 'No argstring required.'
    credentialInterfaces = (IAnonymous,)


    def generateChecker(self, argstring=''):
        return AllowAnonymousAccess()



theAnonymousCheckerFactory = AnonymousCheckerFactory()

